Skip to content

Comments

fix: extract sdkSessionId when reading from logs#190

Merged
jonathanlab merged 1 commit intomainfrom
fix/restore-properly
Dec 3, 2025
Merged

fix: extract sdkSessionId when reading from logs#190
jonathanlab merged 1 commit intomainfrom
fix/restore-properly

Conversation

@jonathanlab
Copy link
Contributor

we werent reading sdkSessionId from the logs anymore, which caused claude to lose context on session restore. this makes sure we extract it from the logs

@jonathanlab jonathanlab requested a review from a team as a code owner December 3, 2025 14:57
notifications.push(stored.notification.params as SessionNotification);
}

// Extract SDK session ID from _posthog/sdk_session notification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this, isn't session id = task run id?

Copy link
Contributor Author

@jonathanlab jonathanlab Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 4 IDs:
Task ID
Task run ID
ACP Session ID
Agent (Claude/Codex/Gemini) SDK ID (This stores context remotely, and is being retrieved in this PR)

We retrieve the logs using Task ID + Task Run ID.

The ACP Session ID is always equivalent to the task run ID.

The Agent SDKs return their own ID once a conversation is created. We store that via _posthog/sdk_session in the log, and retrieve it on session resumption. This ID is used by the provider to store context etc.See also: https://platform.claude.com/docs/en/agent-sdk/sessions

@jonathanlab jonathanlab merged commit ee50912 into main Dec 3, 2025
10 checks passed
@jonathanlab jonathanlab deleted the fix/restore-properly branch December 3, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants